package com.example.channel

import com.example.kotlincoroutine.api.User
import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.junit.Test
import java.io.File

private val cachePath = "/Users/huliangyuan/Downloads/a.txt"
private val gson = Gson()

suspend fun getUserFromLocal(name: String) = withContext(Dispatchers.IO) {
    delay(1000)
    File(cachePath).readText().let {
        gson.fromJson(it, User::class.java)
    }
}

class CoroutineTest02 {

    //通道-多路复用-安全并发


    @Test
    fun `test select await`() = runBlocking<Unit> {

    }

}